package com.wyw.leetcode.learning.simple;

/**
 * leetcode topic 27
 * 移除元素
 *
 * @Author Mr Wu （yewen.wu.china@gmail.com）
 * @Date 2021/10/28 16:21
 */
public class Topic027 {
    public static void main(String[] args) {
        int[] nums = {};
//        int[] nums = {0,0,1,1,1,2,2,3,3,4};
        System.out.println(removeElement(nums, 1));
    }

    public static int removeElement(int[] nums, int val) {
        int j = 0;
        for(int i = 0; i < nums.length; i++) {
            if(nums[i] != val){
                nums[j] = nums[i];
                j++;
            }

        }
        return j;
    }
}
